﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Xml;

namespace Acoris.Sample
{
    using Acoris.Foundation;
    using Acoris.Text;

    class Program
    {
        interface IUName
        {
            void Print();
        }

        class Name:IUName
        {
            static int i = 0;
            public void Print()
            {
                i++;
            }

            public override string ToString()
            {
                return i.ToString();
            }
        }

        const int Times = 10000000;

        static void Main(string[] args)
        {
            Counter1(new Name());

            Counter2((IUName)new Name());
        }

        static void Counter1(object token) {
            Stopwatch dog = new Stopwatch();
            dog.Start();
            for(int i = 0; i < Times; i++)
            {
                if (token is Name name)
                {
                    name.Print();
                }
            }
            dog.Stop();
            Console.WriteLine($"cost:{dog.ElapsedMilliseconds}ms");
        }

        static void Counter2(IUName token)
        {
            Stopwatch dog = new Stopwatch();
            dog.Start();
            for (int i = 0; i < Times; i++)
            {
                token.Print();
            }
            dog.Stop();
            Console.WriteLine($"cost:{dog.ElapsedMilliseconds}ms");
        }
    }
}
